<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<f:view>
    <%--@include file="../jspf/html_inicio.jspf" --%>
    <%--@include file="../jspf/menu_principal.jspf" --%>
    <link href="/evento/css/admin_2.css" rel="stylesheet" type="text/css"/>

    <t:div>


        <h:form id="formulario">

            <h:panelGrid columns="1" width="100%" styleClass="tablaprincipal">
               <h:outputLabel value="Registrar Material Académico" />
            </h:panelGrid>
            <a4j:outputPanel ajaxRendered="true">
                <h:messages id="lblMessages" styleClass="messages" infoClass="infoClass" errorClass="errorClass"
                            warnClass="warnClass" showDetail="true" errorStyle="color:red;"
                            warnStyle="color:green;" infoStyle="color:black;" fatalStyle="color:black"/>
            </a4j:outputPanel>
            <table width="100%" cellpadding="2" cellspacing="2" class="tablanormal">
                <tr>
                    <td width="15%" align="right">Codigo: </td>
                    <td width="85%">
                        <h:outputLabel value="#{MaterialAcademicoController.materialAcademico.macCodigo}" />
                    </td>
                </tr>
                <tr>
                    <td align="right">Curso: </td>
                    <td>
                        <h:selectOneMenu value="#{MaterialAcademicoController.codigoCurso}" disabled="#{MaterialAcademicoController.habilitar}" >
                            <f:selectItem itemLabel="-- Seleccione Curso --"/>
                            <f:selectItems value="#{MaterialAcademicoController.comboCursos}" />
                        </h:selectOneMenu>
                    </td>
                </tr>
                <tr>
                    <td align="right">Titulo: </td>
                    <td><h:inputTextarea value="#{MaterialAcademicoController.materialAcademico.macTitulo}" rows="3" cols="110" disabled="#{MaterialAcademicoController.habilitar}" /></td>
                </tr>
                <tr>
                    <td align="right">Tema: </td>
                    <td><h:inputTextarea value="#{MaterialAcademicoController.materialAcademico.macTema}" rows="3" cols="110" disabled="#{MaterialAcademicoController.habilitar}" /></td>
                </tr>
                <tr>
                    <td align="right">Objetivos: </td>
                    <td><h:inputTextarea value="#{MaterialAcademicoController.materialAcademico.macObjectivos}" rows="3" cols="110" disabled="#{MaterialAcademicoController.habilitar}" /></td>
                </tr>
            </table>

            <h:panelGrid columns="1" width="100%" styleClass="tablaprincipal">
               <h:outputLabel value="Detalle Material Académico" />
            </h:panelGrid>

            <table width="100%" cellpadding="2" cellspacing="2" class="tablanormal">
                <tr>
                    <td width="15%" align="right">Contenido: </td>
                    <td width="85%" valign="middle">
                        <h:inputTextarea value="#{MaterialAcademicoController.detalleMaterial.dmaContenido}" rows="3" cols="80" />
                        &nbsp;
                        <h:commandButton styleClass="desactivar" title="Agregar"
                                         accesskey="A" id="btnAgregar" value="Agregar"
                                         action="#{MaterialAcademicoController.agregarDetalle}" />
                    </td>
                </tr>
            </table>

            <rich:dataTable value="#{MaterialAcademicoController.listaDetalleMaterial}"
                            var="detalle" rows="15" reRender="ds" id="simpletable2"
                            width="100%" columnsWidth="5%,85%,10%">
                <f:facet name="header">
                    <rich:columnGroup>
                        <rich:column colspan="3" >
                            <h:outputLabel value=""/>
                        </rich:column>
                        <rich:column breakBefore="true">
                            <h:outputLabel value="Codigo"/>
                        </rich:column>
                        <rich:column>
                            <h:outputLabel value="Contenido"/>
                        </rich:column>
                        <rich:column>
                            <h:outputLabel value="Opciones"/>
                        </rich:column>
                    </rich:columnGroup>
                </f:facet>
                <rich:column>
                    <h:outputLabel value="#{detalle.dmaCodigo}"/>
                </rich:column>
                <rich:column>
                    <h:inputTextarea value="#{detalle.dmaContenido}" rows="2" cols="80" disabled="true" />
                </rich:column>
                <rich:column>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <h:commandButton value="Eliminar" title="Eliminar" image="/img/eliminar.png"
                                     action="#{MaterialAcademicoController.eliminarDetalle}"
                                     onclick="return confirm('Deseas eliminar el Detalle Material?');">
                        <f:setPropertyActionListener target="#{MaterialAcademicoController.detalleMaterial}" value="#{detalle}" />
                    </h:commandButton>
                </rich:column>
                <f:facet name="footer">
                    <rich:datascroller id="ds" renderIfSinglePage="false"></rich:datascroller>
                </f:facet>
            </rich:dataTable>

            <br/>

            <h:commandButton styleClass="desactivar" title="Retornar"
                             accesskey="R" id="btnRetornar" value="Retornar"
                             action="#{MaterialAcademicoController.listar}" />

            &nbsp;&nbsp;

            <h:commandButton styleClass="desactivar" title="Actualizar"
                             accesskey="G" id="btnGuardar" value="Actualizar"
                             rendered="#{!MaterialAcademicoController.habilitar}"
                             action="#{MaterialAcademicoController.actualizar}"
                             onclick="confirmar('Deseas Actualizar el Formato Certificado?');" />
            &nbsp;&nbsp;

            <h:commandButton styleClass="desactivar" title="Cancelar" type="reset"
                             rendered="#{!MaterialAcademicoController.habilitar}"
                             accesskey="C" id="btnCancelar" value="Cancelar"
                             action = "#{MaterialAcademicoController.cancelar}" />

        </h:form>
    </t:div>
</f:view>
